<template>
  <div class="">
    <div class="page-form">
      <!-- <el-cascader
        v-hasRole="['admin']"
        v-model="queryParams.parentId"
        :options="cityList"
        :props="{
          label: 'deptName',
          value: 'deptId',
          emitPath: false,
        }"
        placeholder="所属地区"
        @change="handleSearch"
        clearable
      ></el-cascader> -->
      <el-select
        v-model="queryParams.subject"
        placeholder="考试名称"
        clearable
        @change="handleSearch"
      >
        <el-option
          v-for="dict in kslb"
          :key="dict.id"
          :label="dict.name"
          :value="dict.id"
        />
      </el-select>
      <el-input
        v-model="queryParams.schoolNumber"
        placeholder="学校代码"
        clearable
        @input="handleSearch"
      />
      <el-input
        v-hasRole="['admin']"
        placeholder="学校名称"
        v-model="queryParams.schoolName"
        clearable
        @input="handleSearch"
      />
    </div>
    <el-table
      stripe
      border
      ref="tableList"
      v-loading="loading"
      :data="tableData"
      style="width: 100%"
      @selection-change="handleSelectionChange"
      row-key="id"
    >
      <el-table-column
        type="selection"
        width="55"
        align="center"
        :reserve-selection="true"
      />
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{
            (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="学校代码"
        align="center"
        prop="schoolNumber"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="学校名称"
        align="center"
        prop="schoolName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="学校别名"
        align="center"
        prop="schoolAlias"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="学校地址"
        align="center"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope" v-if="scope.row.provinceName">
          {{ scope.row.provinceName }}
          /
          {{ scope.row.cityName }}
          /
          {{ scope.row.districtName }}
        </template>
      </el-table-column>
      <el-table-column
        label="上报状态"
        align="center"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          {{ scope.row.reportEnabled == "1" ? "开启上报" : "关闭上报" }}
        </template>
      </el-table-column>
      <el-table-column
        label="上报关闭时间"
        align="center"
        prop="reportCloseTime"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        label="老师上报数量"
        align="center"
        prop="teacherNum"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        label="学生上报数量"
        align="center"
        prop="studentNum"
        :show-overflow-tooltip="true"
      >
      </el-table-column>

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="140"
        v-if="$auth.hasRole('admin')"
      >
        <template slot-scope="scope">
          <el-link type="primary" @click="edit(scope.row)">编辑</el-link>
          <el-link type="primary" @click="cjqxSchool(scope.row)" :disabled="!golbalType">设置权限</el-link>
          <el-link type="danger" @click="del(scope.row.id)">删除</el-link>
        </template>
      </el-table-column>
    </el-table>

    <div class="page-bottom">
      <div class="sel-box">
        <p>
          已选 <span>{{ ids.length }}</span> 项 / 共 {{ total }} 项
        </p>
        <template v-if="$auth.hasRole('admin')">
          <el-button type="primary" @click="edit(false)">单个添加</el-button>
          <el-button type="primary" @click="upload.open = true"
            >批量导入</el-button
          >
          <el-button type="primary" @click="dc">导出学校信息</el-button>
          <el-button type="primary" @click="sb">开启/关闭上报</el-button>
          <el-button type="primary" @click="cjqxGlobal(queryParams)">设置成绩权限</el-button>
          <el-button type="danger" :disabled="multiple" @click="del(false)"
            >批量删除</el-button
          >
        </template>
      </div>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>

    <el-dialog
      ref="editDialog"
      class="editKmVisible"
      title="创建/编辑新学校"
      :visible.sync="editKmVisible"
      width="436px"
      :before-close="beforeClose"
    >
      <el-form
        ref="editForm"
        :model="editForm"
        :rules="rules"
        label-position="left"
        label-width="140px"
      >
        <el-form-item label="学校地址" prop="provinceId">
          <el-select
            v-model="editForm.provinceId"
            placeholder="省"
            @change="provinceChange"
          >
            <el-option
              v-for="item in regionList1"
              :key="item.regionId"
              :label="item.regionName"
              :value="item.regionId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="cityId">
          <el-select
            v-model="editForm.cityId"
            placeholder="市"
            @change="cityChange"
          >
            <el-option
              v-for="item in regionList2"
              :key="item.regionId"
              :label="item.regionName"
              :value="item.regionId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="districtId">
          <el-select v-model="editForm.districtId" placeholder="区/县">
            <el-option
              v-for="item in regionList3"
              :key="item.regionId"
              :label="item.regionName"
              :value="item.regionId"
            ></el-option>
          </el-select>
        </el-form-item>
        <template>
          <el-form-item label="学校名称" prop="schoolName">
            <el-input
              v-model="editForm.schoolName"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item label="学校别名" prop="schoolAlias">
            <el-input
              v-model="editForm.schoolAlias"
              autocomplete="off"
            ></el-input>
          </el-form-item>
        </template>
        <el-form-item label="选择考试" prop="subjects">
          <el-select
            v-model="editForm.subjects"
            multiple
            filterable
            :disabled="editForm.uploadStatus == 1"
          >
            <el-option
              v-for="dict in kslb"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="新学校自动创建管理员"
          label-width="152px"
          v-if="!editForm.id"
        >
          <el-switch
            v-model="editForm.newSchool"
            active-color="#1890ff"
            active-value="1"
            inactive-value="0"
          >
          </el-switch>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose">返 回</el-button>
        <el-button type="primary" @click="editSubmit" :loading="loading"
          >保 存</el-button
        >
      </div>
    </el-dialog>

    <el-dialog
      title="导入"
      :visible.sync="upload.open"
      :close-on-click-modal="false"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?examId=' + xmxx.id"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplate"
            >下载模板</el-link
          >
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          @click="submitFileForm"
          :loading="upload.isUploading"
          >确 定</el-button
        >
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      class="editKmVisible"
      title="开启上报"
      :visible.sync="sbVisible"
      width="436px"
    >
      <p class="tips">
        开启上报后，校管理员可根据通过联考上报上传评阅教师及考生数据，如到达关闭时间后将自动关闭上报通道。
      </p>

      <el-form
        ref="sbForm"
        :model="sbForm"
        label-position="left"
        label-width="140px"
        :rules="sbRules"
      >
        <el-form-item label="上报开关">
          <el-radio v-model="sbForm.reportEnabled" label="2">关闭上报</el-radio>
          <el-radio v-model="sbForm.reportEnabled" label="1">开启上报</el-radio>
        </el-form-item>
        <el-form-item
          label="关闭时间"
          prop="reportCloseTime"
          v-if="sbForm.reportEnabled == '1'"
        >
          <el-date-picker
            v-model="sbForm.reportCloseTime"
            :picker-options="pickerOptions"
            type="datetime"
            placeholder="选择日期时间"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="sbVisible = false">返 回</el-button>
        <el-button type="primary" @click="sbSubmit" :loading="loading"
          >保存并退出</el-button
        >
      </div>
    </el-dialog>
    <!-- 全局 -->
    <el-dialog
  title="成绩查询权限"
  :visible.sync="cjqxDialobVisible"
  width="30%"
  :before-close="cjqxHandleClose">
  <span style="color: #D54941;">此权限为全部学校默认权限，如需单个学校修改请在学校内设置查询权限单独修改！</span>
  <div style="margin-top:10px">学生查询</div>
  <div style="margin-top:10px">
    成绩分析查询
    <el-switch v-model="cjqxForm.studentGradeAnalysisQuery" :active-value="1" :inactive-value="0"></el-switch>


  </div>
  <div style="margin-top:10px">教师查询</div>
  <div style="margin-top:10px">
    成绩查询
    <el-switch v-model="cjqxForm.teacherGradeQuery" :active-value="1" :inactive-value="0"></el-switch>
    <span style="margin-left:10px">分析查询</span>
    <el-switch v-model="cjqxForm.teacherAnalysisQuery" :active-value="1" :inactive-value="0"></el-switch>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="cjqxHandleClose">返回</el-button>
    <el-button type="primary" @click="cjqxHandleOk">保存并退出</el-button>
  </span>
</el-dialog>
<!-- 学校 -->
  <el-dialog
  :title="'成绩查询权限'"
  :visible.sync="cjqxSchoolDialobVisible"
  width="30%"
  :before-close="cjqxSchoolHandleClose">
  <div style="margin-top:10px">学生查询</div>
  <div style="margin-top:10px">
    成绩分析查询
    <el-switch v-model="cjqxSchoolForm.studentGradeAnalysisQuery" :active-value="1" :inactive-value="0"></el-switch>
  </div>
  <div style="margin-top:10px">教师查询</div>
  <div style="margin-top:10px">
    成绩查询
    <el-switch v-model="cjqxSchoolForm.teacherGradeQuery" :active-value="1" :inactive-value="0"></el-switch>
    <span style="margin-left:10px">分析查询</span>
    <el-switch v-model="cjqxSchoolForm.teacherAnalysisQuery" :active-value="1" :inactive-value="0"></el-switch>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="cjqxSchoolHandleClose">返回</el-button>
    <el-button type="primary" @click="cjqxSchoolHandleOk">保存并退出</el-button>
  </span>
</el-dialog>
  </div>
</template>

<script>
import { listDept } from "@/api/system/dept";
import { debounce } from "lodash";
import { subjectpage, 
  gradeQueryPermissionConfig, 
  gradeQueryPermissionConfigAdd,
  gradeQueryPermissionConfigEdit, 
  schoolGradeQueryPermissionConfig, 
  schoolGradeQueryPermissionConfigEdit ,
  gradeQueryPermissionConfigUpdata
} from "@/api/xmgl/ksgl";


import { regionList } from "@/api/common";
import {
  schoollist,
  schoolAdd,
  schoolEdit,
  schoolDel,
  schoolreport,
} from "@/api/xmgl/csxx";
import { checkPassword } from "@/api/common";
import { getToken } from "@/utils/auth";
export default {
  props: {
    xmxx: {},
  },
  data() {
    return {
      schoolId: null,
      loading: false,
      cjqxDialobVisible: false,
      cjqxForm: {
        studentAnalysisQuery : 0,
        teacherAnalysis : 0,
        teacherQuery: 0,
      },
      cjqxSchoolForm: {
        studentAnalysisQuery : 0,
        teacherAnalysis : 0,
        teacherQuery: 0,
      },
      cjqxSchoolDialobVisible: false,



      ids: [],

      total: 0,
      tableData: [],

      multiple: true,

      queryParams: {
        pageNum: 1,
        pageSize: 15,
      },

      editKmVisible: false,
      editForm: {
        schoolName: "",
        schoolAlias: "",
        subjects: [],
        newSchool: "1",
        uploadStatus: "0",
        provinceId: "",
        cityId: "",
        districtId: "",
      },
      rules: {
        schoolName: [
          { required: true, message: "学校名称不能为空", trigger: "change" },
        ],
        subjects: [
          { required: true, message: "考试科目不能为空", trigger: "blur" },
        ],
        provinceId: [
          { required: true, message: "省不能为空", trigger: "change" },
        ],
        cityId: [{ required: true, message: "市不能为空", trigger: "change" }],
        districtId: [
          { required: true, message: "区/县不能为空", trigger: "change" },
        ],
      },
      deptList: [],
      cityList: [],
      kslb: [],

      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/exam/school/import",
      },

      sbVisible: false,
      sbForm: {
        reportEnabled: "1",
        reportCloseTime: "",
      },
      sbRules: {
        reportCloseTime: [
          { required: true, message: "关闭时间不能为空", trigger: "change" },
        ],
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 86400000;
        },
      },

      regionList1: [],
      regionList2: [],
      regionList3: [],
      golbalType:false,// 是否有全局配置

    };
  },
  created() {
    this.getCjqxGlobal();

    if (!this.$auth.hasRole("admin")) {
      console.log(this.$store.state.user);
      this.queryParams.schoolName = this.$store.state.user.deptName;
    }
    this.getList();

    subjectpage({ pageNum: 1, pageSize: 9999, examId: this.xmxx.id }).then(
      (res) => {
        this.kslb = res.rows;
      }
    );

    if (this.$auth.hasRole("admin")) {
      this.getRegion("", "1");

      listDept().then((res) => {
        let deptList = [];
        let cityList = [];
        res.data.map((item) => {
          if (item.type == 1) {
            deptList.push(item);
          } else {
            cityList.push(item);
          }
        });

        this.deptList = deptList;
        cityList = this.handleTree(cityList, "deptId").filter((item) => {
          return item.children && item.children.length > 0;
        });

        cityList.map((item) => {
          item.children.map((v) => {
            delete v.children;
          });
        });
        this.cityList = cityList;
      });
    }
  },
  methods: {
    debouncedSearch: debounce(function () {
      this.queryParams.pageNum = 1;
      this.getList();
    }, 500),

    getRegion(value, level) {
      regionList({
        pageSize: "999999",
        regionLevel: level,
        regionParentId: value,
      }).then((res) => {
        this["regionList" + level] = res.rows;
      });
    },
    cjqxSchool(row){
      this.cjqxSchoolDialobVisible = true;
      this.schoolId = row.schoolId;
      schoolGradeQueryPermissionConfig({examId: this.xmxx.id, schoolId: row.schoolId}).then((res) => {
        if (!res.data) {
          this.cjqxSchoolForm = {
            studentAnalysisQuery : this.cjqxForm.studentAnalysisQuery,
            teacherAnalysis : this.cjqxForm.teacherAnalysis,
            teacherQuery: this.cjqxForm.teacherQuery,
          }
        }else{
          this.cjqxSchoolForm = res.data || {};
        }
      })

    },
    cjqxSchoolHandleOk(){
      let data = {
        examId: this.xmxx.id,
        ...this.cjqxSchoolForm,
        schoolId: this.cjqxSchoolForm.id? this.cjqxSchoolForm.schoolId:this.schoolId,
      }
      schoolGradeQueryPermissionConfigEdit(data).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: "修改成功",
            type: "success",
          });
        this.cjqxSchoolDialobVisible = false;
        }
      })
    },
    cjqxSchoolHandleClose(){
      this.cjqxSchoolDialobVisible = false;
    },
    // 获取全局配置
    getCjqxGlobal(){
      gradeQueryPermissionConfig(this.xmxx.id).then((res) => {
        if (!res.data) {
          this.cjqxForm = {studentAnalysisQuery : 0,
          teacherAnalysis : 0,
          teacherQuery: 0,};
            this.golbalType = false;
        }else{
          this.cjqxForm = res.data
          this.golbalType = true;
        }
      })
    },
    cjqxGlobal(){
      this.cjqxDialobVisible = true;
    },
    cjqxHandleClose(){
      this.cjqxDialobVisible = false;
    },
    cjqxHandleOk(){
      let data = {
        examId: this.xmxx.id,
        ...this.cjqxForm,
      }
      gradeQueryPermissionConfigUpdata(data).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: "修改成功",
            type: "success",
          });
        this.cjqxDialobVisible = false;
        this.getCjqxGlobal();
        }
      })
      return false
      if (this.golbalType) {
        // 存在全局配置 则直接修改
        gradeQueryPermissionConfigEdit(data).then((res) => {
          if (res.code == 200) {
            this.$message({
              message: "修改成功",
              type: "success",
            });
          this.cjqxDialobVisible = false;
          }
        })
      }else{
        // 不存在全局配置 则新增
        data = {
          examId: this.xmxx.id,
          ...this.cjqxForm,
        }
        gradeQueryPermissionConfigAdd(data).then((res) => {
          if (res.code == 200) {
            this.$message({
              message: "新增成功",
              type: "success",
            });
          this.cjqxDialobVisible = false;
          }
        })
      }
    },
    provinceChange(value) {
      this.editForm.cityId = "";
      this.editForm.districtId = "";
      this["regionList2"] = [];
      this["regionList3"] = [];
      this.getRegion(value, "2");
    },
    cityChange(value) {
      this.editForm.districtId = "";
      this["regionList3"] = [];
      this.getRegion(value, "3");
    },
    handleSearch() {
      this.debouncedSearch();
    },
    getList() {
      this.loading = true;
      this.tableData = [];
      schoollist({ ...this.queryParams, examId: this.xmxx.id })
        .then((response) => {
          this.tableData = response.rows || [];
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.multiple = !selection.length;
    },

    edit(row) {
      if (row) {
        this.editForm.id = row.id;
        this.editForm.provinceId = row.provinceId;
        // this.provinceChange(row.provinceId, "2");
        this.getRegion(row.provinceId, "2")
        this.editForm.cityId = row.cityId;
        this.getRegion(row.cityId, "3")
        // this.provinceChange(row.cityId, "3");
        this.editForm.districtId = row.districtId;
        this.editForm.schoolName = row.schoolName;
        this.editForm.schoolAlias = row.schoolAlias;
        this.editForm.newSchool = row.newSchool;
        this.editForm.uploadStatus = row.uploadStatus;
        this.editForm.subjects = row.examSchoolSubjectList.map((item) => {
          return item.examSubjectId;
        });
      }

      this.editKmVisible = true;
    },

    beforeClose(done) {
      this.editForm = {
        schoolName: "",
        schoolAlias: "",
        uploadStatus: "0",
        subjects: [],
        newSchool: "1",
        provinceId: "",
        cityId: "",
        districtId: "",
      };
      this.regionList2 = [];
      this.regionList3 = [];
      this.$nextTick(() => {
        this.$refs.editForm.clearValidate();
        done();
      });
    },
    handleClose() {
      this.beforeClose(() => {
        this.editKmVisible = false;
      });
    },

    editSubmit() {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.loading = true;
          let req;
          if (this.editForm.id) {
            req = schoolEdit;
          } else {
            req = schoolAdd;
          }
          let data = {
            ...this.editForm,
            examId: this.xmxx.id,
          };

          data.provinceName = this.regionList1.find((item) => {
            return item.regionId == data.provinceId;
          }).regionName;
          data.cityName = this.regionList2.find((item) => {
            return item.regionId == data.cityId;
          }).regionName;
          data.districtName = this.regionList3.find((item) => {
            return item.regionId == data.districtId;
          }).regionName;

          let subjects = [];
          this.kslb.map((item) => {
            if (data.subjects.indexOf(item.id) != "-1") {
              subjects.push({
                subjectName: item.subjectName,
                subjectId: item.subjectId,
                examSubjectId: item.id,
                examSubjectName: item.name,
                examId: this.xmxx.id,
              });
            }
          });
          data.subjects = subjects;

          req(data)
            .then((res) => {
              this.$modal.msgSuccess("操作成功");
              this.handleClose();
              this.getList();
            })
            .finally(() => {
              this.loading = false;
            });
        }
      });
    },
    dc() {
      this.download(
        "/system/exam/school/export",
        {
          examId: this.xmxx.id,
        },
        `考试参与学校_${new Date().getTime()}.xlsx`
      );
    },
    del(id) {
      this.$prompt(
        "删除学校后，可能造成学校下级数据全部清空导致数据的缺失，请输入管理员密码以进行下步操作",
        "删除学校",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          inputPlaceholder: "请输入管理员密码",
          inputType: "password",
          inputValidator: (value) => {
            if (!value) {
              return "请输入密码";
            } else {
              return true;
            }
          },
        }
      )
        .then(({ value }) => {
          checkPassword({
            password: value,
            schoolId: this.$store.state.user.deptId,
          }).then((res) => {
            schoolDel(id ? id : this.ids).then((res) => {
              this.$modal.msgSuccess("操作成功");
              this.$refs.tableList.clearSelection();
              this.ids = [];
              this.getList();
            });
          });
        })
        .catch(() => {});
    },

    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      window.open(
        "https://bs-exam-bucket.oss-cn-beijing.aliyuncs.com/dev/bsta/exam/uploadPath/upload/template/exam_school_template.xlsx"
      );
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(
        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
          response.msg +
          "</div>",
        "导入结果",
        { dangerouslyUseHTMLString: true }
      );
      this.allDeptList = null;
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    sb() {
      this.sbForm = {
        reportEnabled: this.tableData[0].reportEnabled.toString(),
        reportCloseTime: this.tableData[0].reportCloseTime,
      };
      this.sbVisible = true;
      this.$nextTick(() => {
        this.$refs.sbForm.clearValidate();
      });
    },
    sbSubmit() {
      this.$refs.sbForm.validate((valid) => {
        if (valid) {
          this.loading = true;
          schoolreport({ ...this.sbForm, examId: this.xmxx.id })
            .then((res) => {
              this.$modal.msgSuccess("操作成功");
              this.sbForm = {
                reportEnabled: "1",
                reportCloseTime: "",
              };
              this.sbVisible = false;
              this.$refs.tableList.clearSelection();
              this.ids = [];
              this.getList();
            })
            .finally(() => {
              this.loading = false;
            });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.editKmVisible {
  .el-input,
  .el-cascader,
  .el-select {
    width: 240px;
  }
}
.tips {
  color: #c03639;
  margin: 0;
}
</style>